package xc.com.course.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xc.com.common.PageVo;
import xc.com.common.Result;
import xc.com.course.domain.CourseBase;
import xc.com.course.service.CourseBaseService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuolizhong
 * @since 2021-06-03
 */
@RestController
@RequestMapping("/course-base")
@Api(tags = "courseBase接口",description = "课程信息增删改查")
@CrossOrigin
public class CourseBaseController {

    @Autowired
    private CourseBaseService courseBaseService;

    /**
     * 查询所有课程信息
     * @param pageNum
     * @return
     */
    @PostMapping("/findall/{pageNum}")
    @ApiOperation("查询所有课程信息")
    public PageVo<CourseBase> findall(@PathVariable("pageNum")Integer pageNum,@RequestBody CourseBase courseBase){
     return courseBaseService.findall(pageNum,courseBase);
    }

    /**
     * 添加课程信息
     * @param courseBase
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("添加课程信息")
    public Result<CourseBase> add(@RequestBody CourseBase courseBase){
        Result result = courseBaseService.addcoursebase(courseBase);
        return result;
    }

    /**
     * 根据课程id查询课程基础信息
     * @param courseId
     * @return
     */
    @GetMapping("/selectById/{courseId}")
    public CourseBase selectById(@PathVariable("courseId") String courseId){
   return  courseBaseService.findById(courseId);
    }

    /**
     * 修改课程基础信息
     * @param courseBase
     * @return
     */
    @PutMapping("/update")
    public Result updateByCourseId(@RequestBody CourseBase courseBase){
     return courseBaseService.updateByCourseId(courseBase);
    }
}

